﻿<Window x:Class="FlowStudio.OptionsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:exwpf="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
        Title="Options" 
        WindowStyle="ToolWindow" 
        WindowStartupLocation="CenterOwner" 
        ResizeMode="CanResizeWithGrip" 
        ShowInTaskbar="False"
        DataContext="{Binding OptionsViewModel, Source={StaticResource ModelLocator}}" 
        MinWidth="550" 
        MinHeight="350"
        Width="550" 
        Height="350">
    
    <Grid Margin="12">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <TabControl Grid.Row="0">
            
            <TabItem Header="Debug">
                <Border Margin="5" BorderThickness="1" BorderBrush="#FFABADB3">
                    <Grid Margin="12">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <exwpf:IntegerUpDown FormatString="N0" Increment="50"
                                             Minimum="{Binding MinimumMillisecondsBetweenDebugSteps}"
                                             Maximum="{Binding MaximumMillisecondsBetweenDebugSteps}"
                                             Value="{Binding MillisecondsBetweenDebugSteps, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                             Grid.Column="0" Grid.Row="0" Height="24" Width="100" />
                        <Label Content="milliseconds between debug steps" Grid.Column="1" Grid.Row="0" />
                    </Grid>
                </Border>    
            </TabItem>
            
            <TabItem Header="References Directories" Grid.Row="0">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <ListBox ItemsSource="{Binding ReferencesPaths}" Grid.Row="0" SelectionMode="Multiple" 
                             Name="ReferencesPathsListBox">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="{x:Type ListBoxItem}">
                                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                                <Setter Property="ToolTip" Value="{Binding DirectoryPath}" />
                            </Style>
                        </ListBox.ItemContainerStyle>
                        <ListBox.InputBindings>
                            <KeyBinding Key="Delete" Command="{Binding RemoveSelectedReferencesPathsCommand}"/>
                        </ListBox.InputBindings>
                    </ListBox>
                
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Button Content="Add..." Grid.Column="0" Margin="0,10,10,0" Padding="5"
                                Command="{Binding AddReferencePathCommand}" />
                        <Button Content="Remove Selected" Grid.Column="1" Margin="0,10,10,0" Padding="5"
                                Command="{Binding RemoveSelectedReferencesPathsCommand}"/>
                        <Button Content="Remove All" Grid.Column="2" Margin="0,10,0,0" Padding="5"
                                Command="{Binding RemoveAllReferencesPathsCommand}"/>
                    </Grid>
                </Grid>
            </TabItem>
        </TabControl>
        
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            
            <Button Content="Ok" Grid.Column="1" Margin="10,10,0,0" Width="80" Height="25" IsDefault="True"
                    Command="{Binding SaveOptionsCommand}" />
            <Button Content="Cancel" Grid.Column="2" Margin="10,10,0,0" Width="80" Height="25" IsCancel="True"
                    Command="{Binding CloseOptionsCommmand}" />
        </Grid>
    </Grid>
    
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closed">
            <cmd:EventToCommand Command="{Binding CloseOptionsCommmand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</Window>
